import { Image } from 'antd';
import { baseURL } from '../../../config';
import MaintainModal from './maintainModal';
const columns = [
	{
		title: '房间Id',
		dataIndex: 'id',
	},
	{
		title: '图片',
		dataIndex: 'url',
		width: '120px',
		render: (text, record) => {
			return (
				<Image
					key={record.url}
					width={100}
					height={100}
					src={`${baseURL}\\images\\${record.url}.jpg`}
					fallback=''
				/>
			);
		},
		editable: true,
		inputType: 'image',
	},
	{
		title: '房间名',
		dataIndex: 'name',
		sorter: {
			compare: (a, b) => a.name.localeCompare(b.name),
			multiple: 3,
		},
		search: true,
		editable: true,
		rules: [
			{
				required: true,
				message: `房间名不能为空`,
			},
		],
	},
	{
		title: '户型',
		dataIndex: 'housetype',
		sorter: {
			compare: (a, b) => a.housetype.localeCompare(b.housetype),
			multiple: 3,
		},
		editable: true,
		rules: [
			{
				required: true,
				message: `户型不能为空`,
			},
		],
	},
	{
		title: () => {
			return (
				<span>
					面积&#x28;m<sup>2</sup>&#x29;
				</span>
			);
		},
		dataIndex: 'area',
		sorter: {
			compare: (a, b) => a.area > b.area,
			multiple: 3,
		},
		editable: true,
		inputType: 'number',
		rules: [
			{
				required: true,
				message: `面积不能为空`,
			},
		],
	},
	{
		title: '价格(元/月)',
		dataIndex: 'price',
		sorter: {
			compare: (a, b) => a.price > b.price,
			multiple: 3,
		},
		editable: true,
		inputType: 'number',
		rules: [
			{
				required: true,
				message: `价格不能为空`,
			},
		],
	},
	{
		title: '朝向',
		dataIndex: 'dir',
		sorter: {
			compare: (a, b) => a.dir.localeCompare(b.dir),
			multiple: 3,
		},
		editable: true,
		rules: [
			{
				required: true,
				message: `朝向不能为空`,
			},
		],
	},
	{
		title: '是否已经出租',
		dataIndex: 'issell',
		sorter: {
			compare: (a, b) => a.issell > b.issell,
			multiple: 3,
		},
		render: (text, record) =>
			text === '1' ? <span>是</span> : <span>否</span>,
	},
	{
		title: '标签',
		dataIndex: 'tags',
		width: '20%',
		editable: true,
		inputType: 'textarea',
		ellipsis: true,
		rules: [
			{
				required: true,
				message: `标签不能为空`,
			},
		],
	},
	{
		title: '维修',
		dataIndex: 'maintain',
		render: (text, record) => <MaintainModal record={record} />,
	},
];

export default columns;
